package liquidfs.core;

import java.util.*;
import java.util.concurrent.*;

import liquidfs.*;
import liquidfs.data.*;
import liquidfs.data.ex.*;
import liquidfs.data.ops.*;

public class ProblemBox {
   
   private Application app;
   private List<Problem> problems;
   
   public ProblemBox (Application app) {
      this.app = app;
      this.problems = Collections.synchronizedList(new ArrayList<Problem>(20));
   }
   
   public Problem addProblem (Operation<?> operation, FileSystemException exception) {
      Problem problem = new Problem(operation, exception);
      this.problems.add(problem);
      return problem;
   }
   
   public void addProblem (Problem problem) {
      this.problems.add(problem);
   }
   
   public void removeProblem (Problem problem) {
      this.problems.remove(problem);
   }
   
   public void removeProblem (int index) {
      this.problems.remove(index);
   }
   
   public void clearProblems () {
      this.problems.clear();
   }
   
   public int getCount () {
      return this.problems.size();
   }
   
   public Problem getProblem (int index) {
      return problems.get(index);
   }
}
